import {defineStore} from 'pinia'

export const useLayout = defineStore('Layout', {
    state: () => {
        return {
            zhankai: false,  // 侧边导航栏的收缩和展开
            lockscreen: false,   // 全局锁屏状态
        }
    },
    actions: {
        changezhankai(jieguo = null) {
            if (jieguo === null) {
                this.zhankai = !this.zhankai
            } else {
                this.zhankai = jieguo
            }
        },
        changelock(jieguo = null) {
            if (jieguo === null) {
                this.lockscreen = !this.lockscreen;
            } else {
                this.lockscreen = jieguo
            }
        }
    },
    // pinia持久化
    persist: {
        key: 'storekey',    // 加密
        storage: window.sessionStorage, // 存储位置
    },
})
